package cn.iocoder.yudao.module.erp.dal.mysql.warningrules;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.erp.controller.admin.warningrules.vo.WarningRulesPageReqVO;
import cn.iocoder.yudao.module.erp.dal.dataobject.warningrules.WarningRulesDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * ERP 预警规则 Mapper
 *
 * @author 源码
 */
@Mapper
public interface WarningRulesMapper extends BaseMapperX<WarningRulesDO> {

    default PageResult<WarningRulesDO> selectPage(WarningRulesPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WarningRulesDO>()
                .eqIfPresent(WarningRulesDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(WarningRulesDO::getProductId, reqVO.getProductId())
                .eqIfPresent(WarningRulesDO::getCategoryId, reqVO.getCategoryId())
                .likeIfPresent(WarningRulesDO::getCategoryName, reqVO.getCategoryName())
                .eqIfPresent(WarningRulesDO::getUnitId, reqVO.getUnitId())
                .likeIfPresent(WarningRulesDO::getUnitName, reqVO.getUnitName())
                .eqIfPresent(WarningRulesDO::getStandard, reqVO.getStandard())
                .eqIfPresent(WarningRulesDO::getMaxValueType, reqVO.getMaxValueType())
                .eqIfPresent(WarningRulesDO::getMaxValue, reqVO.getMaxValue())
                .eqIfPresent(WarningRulesDO::getMinValue, reqVO.getMinValue())
                .eqIfPresent(WarningRulesDO::getMinValueType, reqVO.getMinValueType())
                .eqIfPresent(WarningRulesDO::getExpirydateValue, reqVO.getExpirydateValue())
                .eqIfPresent(WarningRulesDO::getDetainValue, reqVO.getDetainValue())
                .betweenIfPresent(WarningRulesDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WarningRulesDO::getId));
    }

}